﻿using UnityEngine;
namespace LitBT
{
    /// <summary>
    /// 等待节点
    /// 等待时间内返回Running
    /// 结束后返回Success
    /// </summary>
    public class WaitNode : ActionNode
    {
        /// <summary>
        /// 等待时间
        /// </summary>
        public float duration = 1;
        /// <summary>
        /// 开始时间
        /// </summary>
        float startTime;
        protected override void OnStart()
        {
            startTime = Time.realtimeSinceStartup;
        }

        protected override void OnStop()
        {

        }

        protected override State OnUpdate()
        {
            if (duration < Time.realtimeSinceStartup - startTime)
            {
                return State.Running;
            }
            return State.Success;
        }
    }
}